<?php
App::uses('AttachmentBehavior', 'Uploader.Model/Behavior');

class User extends AppModel {
	
// 	public $actsAs = array(
// 			'Uploader.Attachment' => array(
// 					'photo' => array(
// 							'nameCallback' => 'rename',
// 					)
// 			)
// 	);
	
	public $primaryKey = '_id';
	var $mongoSchema = array(
			'username' => array('type' => 'string'),
			'password' => array('type' => 'string'),
			'created' => array('type' => 'datetime'),
			'facebook_id' => array('type' => 'integer'),
                         'role' => array('type' => 'string'),
                         'modified' => array('type' => 'datetime'),
			 
// 			'photo' => array('type' => 'string'),
			);
	
	public function rename($name, $file) {
		return md5(time());
	}
        public function beforeSave($options = array()) {
    if (isset($this->data[$this->alias]['password'])) {
        $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
    }
    return true;
}
}
?>